import { useModel } from "umi";

const useCheckInstitutionName = () => {
    const { graphqlFetch } = useModel("global");

    const checkInstitutionName = async ({ oiName }) => {
        let res = await graphqlFetch({
            query: `query MyQuery($oiName: String!) { a: allOrganizationInstitutions(condition: { oiName: $oiName }) { totalCount } }`,
            variables: { oiName },
        });
        return res ? res.a.totalCount : null;
    };

    return { checkInstitutionName };
};

export default useCheckInstitutionName;
